<template>
  <div>
    <h1>首页</h1>
    <div>{{userName}},欢迎你！</div>
    <Button type="info" @click="toTest">跳转到测试页</Button>
  </div>
</template>

<script>
import { mapMutations } from 'vuex';
export default {
  data() {
    return {
      userName:'张三', 
    };
  },
  
  mounted() {
    this.setUserName(this.userName);
  },
  methods: {
    ...mapMutations(['setUserName']),
    toTest() {
      this.$router.push({ 
        path: '/test', 
        query: {}
      });
    },
  },
};
</script>
<style lang="less" scoped>

</style>